﻿using System.Configuration;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Configuration
{
    /// <summary>
    /// 数据库连接
    /// </summary>
    public class DataSourceConfig
    {
        static string dataSourceString = null;
        //public static string ConnectionString = "Data Source = DESKTOP-7E4LREC\\SQLEXPRESS;Initial Catalog=pump; User ID=sa; Password=Xyj_0930_1";
        
        //public static string ConnectionString = "Data Source = DESKTOP-7E4LREC\\SQLEXPRESS;Initial Catalog=pump;Integrated Security=True";
        //实验室电脑
        //public static string ConnectionString = "Data Source=DESKTOP-5RTP37A\\SQLEXPRESS;Initial Catalog=pump;Integrated Security=True";
        //温州环境
        //public static string ConnectionString = "Data Source = DESKTOP-2FV181E\\SQLEXPRESS;Initial Catalog=pump;Integrated Security=True";
        public static string DataSourceString
        {
            get
            {
                if (dataSourceString == null)
                {
                    dataSourceString = InitConfig.getString("DataSource", "DataSourceString", "Data Source = DESKTOP-G96IM9M||SQLEXPRESS;Initial Catalog=pump;Integrated Security=True");
                }
                dataSourceString = dataSourceString.Replace("||", @"\");
                // String test = InitConfig.getString("DataSource", "TEST", "Data Source = DESKTOP - 7E4LREC\\SQLEXPRESS; Initial Catalog = pump; User ID = sa; Password = Xyj_0930_1");

                return dataSourceString;
                //return ConfigurationManager.AppSettings["DataSourceString"];
            }
        }

        /*  
        public class DataSource
        {
            public static string DataSourceString
            {
                get
                {
                    return ConfigurationManager.AppSettings["DataSourceString"];
                }
                set
                {
                    Common.refreshConfig("DataSourceString", value);
                }
            }
        }
        */ 
    }
}
